

import java.util.*;
import java.util.Map.Entry;

public class test1 {

	public static void main(String[] args) {
		Map<Integer, String> everyline = new TreeMap<Integer, String>();
		Map<String, List> map = new TreeMap<String, List>();
		Scanner input = new Scanner(System.in);
		Integer l = 0;
		while (input.hasNextLine()) {
			String line = input.nextLine();
			if (!line.equals("!!!!!")) {
				l++;
				everyline.put(l, line);
				String[] str = line.split(" ");
				List<String> letter = new ArrayList<String>();
				for (int i = 0; i < str.length; i++) {

					if (!str[i].equals("")) {
						List<Integer> arr = new ArrayList<Integer>();
						if (!map.containsKey(str[i])) {

							arr.add(l);
							map.put(str[i], arr);
						} else {
							arr = map.get(str[i]);
							if (!arr.contains(l))
								arr.add(l);
							map.put(str[i], arr);
						}
					}
				}
			} else
				break;
		}

		for (Entry<String, List> entry : map.entrySet()) {
			System.out.println(entry.getKey() + "=" + entry.getValue());
		}

		while (input.hasNextLine()) {

			String line = input.nextLine();
			List search = Arrays.asList(line.split(" "));
			List<Integer> list = new ArrayList<Integer>();
			for (Entry<Integer, String> entry : everyline.entrySet()) {
				List letter = Arrays.asList(entry.getValue().split(" "));
				if (search.isEmpty())
					break;
				if (letter.containsAll(search)) {
					list.add(entry.getKey());
				}
			}
			if (!list.isEmpty()) {
				System.out.println(list);
				for (Integer integer : list) {
					System.out.println("line " + integer + ":" + everyline.get(integer));
				}
			} else
				System.out.println("found 0 results");
		}
	}
}
